/*
 * 文件名：WeXinAgentInfo.java
 * 版权：© Copyright 2012-2018 广州宝锶信息技术有限公司
 * 创建人：曾毅
 * 创建时间：2017年5月5日 下午5:47:58
 * 修改人：
 * 修改时间：
 * 需改内容：
 * 
 */
package com.baothink.weichat.dto.common;

import java.util.Arrays;
import java.util.List;

import com.baothink.weichat.utils.StringUtil;


/**
 * TODO<一句话功能描述>
 * TODO<功能详细描述>
 * 
 * @author  曾毅
 * @version 1.0，2017年5月5日 下午5:47:58
 * @since   ASSCWeb1.0
 */
public class WeichatAgentInfo {
    
    private String errcode;
    private String errmsg;
    private String agentid;
    private String name;
    private String square_logo_url;
    private String round_logo_url;
    private String home_url;
    private String description;
    private AllowUserinfos allow_userinfos;
    private AllowPartys allow_partys;
    private AllowTags allow_tags;
    private Integer close;
    private String redirect_domain;
    private Integer report_location_flag;
    private Integer isreportuser;
    private Integer isreportenter;
    private String chat_extension_url;
    private Integer type;
    private long getInfoTime;
    
    
    public WeichatAgentInfo(){}
    
    public String getErrcode() {
        return this.errcode;
    }

    
    public void setErrcode(String errcode) {
        this.errcode = errcode;
    }

    
    public String getErrmsg() {
        return this.errmsg;
    }

    
    public void setErrmsg(String errmsg) {
        this.errmsg = errmsg;
    }

    
    public String getAgentid() {
        return this.agentid;
    }

    
    public void setAgentid(String agentid) {
        this.agentid = agentid;
    }

    
    public String getName() {
        return this.name;
    }

    
    public void setName(String name) {
        this.name = name;
    }

    
    public String getSquare_logo_url() {
        return this.square_logo_url;
    }

    
    public void setSquare_logo_url(String square_logo_url) {
        this.square_logo_url = square_logo_url;
    }

    
    public String getRound_logo_url() {
        return this.round_logo_url;
    }

    
    public void setRound_logo_url(String round_logo_url) {
        this.round_logo_url = round_logo_url;
    }

    
    public String getDescription() {
        return this.description;
    }

    
    public void setDescription(String description) {
        this.description = description;
    }

    
    public AllowUserinfos getAllow_userinfos() {
        return this.allow_userinfos;
    }

    
    public void setAllow_userinfos(AllowUserinfos allow_userinfos) {
        this.allow_userinfos = allow_userinfos;
    }

    
    public AllowPartys getAllow_partys() {
        return this.allow_partys;
    }

    
    public void setAllow_partys(AllowPartys allow_partys) {
        this.allow_partys = allow_partys;
    }

    
    public AllowTags getAllow_tags() {
        return this.allow_tags;
    }

    
    public void setAllow_tags(AllowTags allow_tags) {
        this.allow_tags = allow_tags;
    }

    
    public Integer getClose() {
        return this.close;
    }

    
    public void setClose(Integer close) {
        this.close = close;
    }

    
    public String getRedirect_domain() {
        return this.redirect_domain;
    }

    
    public void setRedirect_domain(String redirect_domain) {
        this.redirect_domain = redirect_domain;
    }

    
    public Integer getReport_location_flag() {
        return this.report_location_flag;
    }

    
    public void setReport_location_flag(Integer report_location_flag) {
        this.report_location_flag = report_location_flag;
    }

    
    public Integer getIsreportuser() {
        return this.isreportuser;
    }

    
    public void setIsreportuser(Integer isreportuser) {
        this.isreportuser = isreportuser;
    }

    
    public Integer getIsreportenter() {
        return this.isreportenter;
    }

    
    public void setIsreportenter(Integer isreportenter) {
        this.isreportenter = isreportenter;
    }

    
    public String getChat_extension_url() {
        return this.chat_extension_url;
    }

    
    public void setChat_extension_url(String chat_extension_url) {
        this.chat_extension_url = chat_extension_url;
    }

    
    public Integer getType() {
        return this.type;
    }

    
    public void setType(Integer type) {
        this.type = type;
    }
    
    public boolean hasPrivileges(String userCode){
        List<User> users = allow_userinfos.getUser();
        if(!StringUtil.isEmptyOrNull(userCode)&&null!=users&&0<users.size()){
            for (User user : users) {
                if(!StringUtil.isEmptyOrNull(user.getUserid())&&Arrays.asList(userCode.split("\\|")).contains(user.getUserid())){
                    return true;
                }
            }
        }
        return false;
    }

    public String getAllowUsers(){
        StringBuffer sb = new StringBuffer();
        if(null!=allow_userinfos){
            List<User> users = allow_userinfos.getUser();
            if(null!=users){
                for (User user : users) {
                    String userid = user.getUserid();
                    String status = user.getStatus();
                    if(!StringUtil.isEmptyOrNull(userid)&&!StringUtil.isEmptyOrNull(status)&&"1".equals(status)){
                        sb.append(userid).append("|");
                    }
                }
                if(sb.length()>0){
                    sb.delete(sb.length()-1, sb.length());
                }
            }
        }
        
        return sb.toString();
    }
    
    public long getGetInfoTime() {
        return getInfoTime;
    }

    public void setGetInfoTime(long getInfoTime) {
        this.getInfoTime = getInfoTime;
    }

    public String getHome_url() {
        return home_url;
    }

    public void setHome_url(String home_url) {
        this.home_url = home_url;
    }

    public static class AllowUserinfos{
        private List<User> user;

        public AllowUserinfos(){}
        
        public List<User> getUser() {
            return this.user;
        }

        
        public void setUser(List<User> user) {
            this.user = user;
        }
        
        
    }
    
    public static class User{
        
        private String userid;
        private String status;
        
        public User(){}
        
        public String getUserid() {
            return this.userid;
        }
        
        public void setUserid(String userid) {
            this.userid = userid;
        }
        
        public String getStatus() {
            return this.status;
        }
        
        public void setStatus(String status) {
            this.status = status;
        }
        
        
    }
    
    public static class AllowPartys{
        
        private int [] partyid;

        public AllowPartys(){}
        
        public int[] getPartyid() {
            return this.partyid;
        }

        
        public void setPartyid(int[] partyid) {
            this.partyid = partyid;
        }
        
        
    }
    
    public static class AllowTags{
        
        private int [] tagid;

        public AllowTags(){}
        
        public int[] getTagid() {
            return this.tagid;
        }
        
        public void setTagid(int[] tagid) {
            this.tagid = tagid;
        }
        
    }
}
